<?php

require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';

class Foo
{
    public $val = 1;
}

class User
{
    private int $id;
    public int $age;
    public string $name;
    private Foo $foo;

    public function __construct(Foo $foo, $id)
    {
        $this->foo = $foo;
        $this->id = $id;
    }
}

class Student extends \yii\base\BaseObject
{
    private int $id;
    public int $age;
    public string $name;
    private Foo $foo;

    public function __construct(Foo $foo, $id, $config = [])
    {
        parent::__construct($config);
        $this->foo = $foo;
        $this->id = $id;
    }
}

$container = Yii::$container;
$user = $container->get(User::class,
    [1 => 123],
    [
        'name' => 'Grey',
        'age'  => 28,
    ]);

$student = $container->get(User::class,
    [1 => 123,],
    [
        'name' => 'Red',
        'age'  => 26,
    ]);

die(0);